import type { RouteRecordRaw } from 'vue-router'
import { HOME_URL, LOGIN_URL } from '@/constants/global'
import Layout from '@/layouts/index.vue'

/** 静态路由 */
const staticRouter: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: HOME_URL,
  },
  {
    path: LOGIN_URL,
    name: 'login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '登录',
      isFull: true,
    },
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register/index.vue'),
    meta: {
      title: '注册',
      isFull: true,
    },
  },
  {
    path: '/layout',
    name: 'layout',
    component: Layout,
    redirect: HOME_URL,
    children: [],
  },
]

/** 错误页面路由 */
const errorRouter = [
  {
    path: '/404',
    name: '404',
    component: () => import('@/components/common/404.vue'),
    meta: {
      title: '404页面',
    },
  },
  {
    path: '/:pathMatch(.*)*', // 匹配所有路径
    component: () => import('@/components/common/404.vue'),
  },
]

export function initStaticRouter() {
  return [...staticRouter, ...errorRouter]
}
